const App = {
    mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            page: {
                value1: '',
                value2: '',
                PageNumber: 1, //页码
                RowAmount: 10,
                Condition: window.btoa(unescape(encodeURIComponent("%%,%%,%%"))),
                ExtensionCondition: window.btoa(unescape(encodeURIComponent(" AND party_organization.Party_Organization_SerialNumber in (" + getCookie("party") + ")"))),
                // ExtensionCondition: '',
            },
            str1:" AND party_organization.Party_Organization_SerialNumber in (" + getCookie("party") + ")",
            str2:''
        }
    },
    mounted() {
        
    },
    methods: {
        Treedata() {
            const _this = this;
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/permissionsTree/getPartyOrganizationsTreeByPermissions`,
                type: "GET",
                data: {
                    PartyOrganizationsCode: getCookie('party'), //请求参数
                },
                success: (data) => {
                    this.treeData = data;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
        },
        check() {
            // let strWhere = ''
            // if (this.page.value1) {
            //     strWhere += " and videos.Video_Name like '%" + this.page.value1 + "%'"
            // }

            // if (this.page.value2) {
            //     strWhere += " and personal_information.Personal_Name like '%" + this.page.value2 + "%'"
            // }
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%%,%"+this.page.value1+"%,%"+this.page.value2+"%"))),
            // console.log("strWhere", strWhere);

            // this.page.ExtensionCondition = window.btoa(unescape(encodeURIComponent(strWhere)));
            this.postgetList(this.page)
        },
        //树的点击筛选事件
        handleNodeClick(data, node) {
            this.nodeKey = data.Party_Organization_SerialNumber;
            this.nodeName = data.Party_Organization_Name;
            let arr = [];
            if (data.children) {
                this.Organization(data.children, arr);
            }
            let str = "";
            [data.Party_Organization_SerialNumber, ...arr].forEach((item) => {
                if (str) {
                    str += "\r\nOR party_organization.Party_Organization_SerialNumber='" + item + "'";
                } else {
                    str = "\r\nparty_organization.Party_Organization_SerialNumber='" + item + "'";
                }
            });
            if (str) {
                str = "AND (" + str + ")";
            }
            this.str2 = str
            this.page.ExtensionCondition = window.btoa(unescape(encodeURIComponent(this.str1 + this.str2)));
            // 调用获取表格数据的方法，并传入党组织编号作为过滤条件
            this.postgetList(this.page);
        },
        Organization(data, arr) {
            data.forEach((item) => {
              arr.push(item.Party_Organization_SerialNumber);
              if (item.children && item.children.length > 0) {
                this.Organization(item.children, arr);
              }
            });
        },
        CategoryAdd() {
            window.location.href = "./add.html?action=Add";
        },

    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
